function reload_captcha(cid,mod){
	$('#' + cid).fadeOut(150);
	var pIm = new Image();
	pIm.src = link_root + 'captcha/' + mod + '/rand-' + Math.random();
	pIm.onload = function(){
		$('#' + cid).attr({src: pIm.src}).fadeIn(150);
	}
}
function au_ajax(loadModule,params,responseElemId,loadWindow,little,oncomp){
	if (loadWindow) {
		loadwin(true ,responseElemId,little);
	}
	little = little || 0;
	oncomp = oncomp || function(data){
			$('#' + responseElemId).html(data.responseText);
			loadwin(false,responseElemId,little);
		};
	$.ajax({
		url: loadModule ? link_root + 'index-ajax.php?module='+loadModule : link_root + 'index-ajax.php',
		dataType : "html",
		complete : oncomp,
		type: 'post',
		data: params
	});
}
function loadwin(boolval,ElemId,useNonw){
	if (boolval){
		if (useNonw) {
			$('#' + ElemId).html('<img src="' + link_root + 'templates/' + template + '/system/ajax.gif" />');
		} else {
			if (!document.getElementById('auInfo')){
				$("<div style='top: 0;left: 0;display:none;' class=\"auInfo\" id=\"auInfo\"><div class='auInfoText'>" + lang['pleaseWait'] + "</div><div align='center'><img align='center' src=\"" + link_root + 'templates/' + template + "/system/ajax.gif\" /></div></div>").appendTo("body");
			}
			$("#auInfo")
			.css({top: $(window).scrollTop() + $(window).height() / 2,left:($(window).width() / 2) - 125})
			.show(50);
		}
	} else {
		if (useNonw) return;
		$("#auInfo").hide(50);
	}
	return 0;
}
function expand(ths){
	if (!document.getElementById('expand')){
		$("<div style=\"display:none;z-index:90;position:absolute;top:0;left:0;\" id='expand'></div>").appendTo("body");
	}
	$("#expand").hide(300).css({top:0,left: 0});
	$("#expand-img").css({'padding':0});
	var Marge = 20;//Margin on image
	var pIm = new Image();
	pIm.src = ths.src;
	pIm.onload = function(){
		var wW = $(window).width();
		var wH = $(window).height();
		var hgh = '';
		var fullexpandI = false;
		var ToP = $(window).scrollTop();
		var docW = $(document).width();
		var docH = $(document).height();
		var vidnosh = 1;
		var imW = pIm.width;
		var imH = pIm.height;
		if(wW - imW < 0){
			var vidnosh = wW / imW;
		}
		if (wH - imH < 0) {
			var vidnosh = wH / imH;
		}
		vidnosh *= 100;
		vidnosh = Math.floor(vidnosh) / 100;
		$("#expand").html('<img id="expand-img" width="' + ((imW * vidnosh) - Marge) + '" src="' + ths.src + '" />');

		if(vidnosh == 1){ // image is smaller than screen
			ToP += (wH - imH) / 2;
		} else {//Show link to full image
			$('<div style="z-index:91;position:absolute;top:0;left:0;" id="expand-fimage"><img src="' + link_root +"templates/"+ template + '/system/fullexpand.gif" /></div>')
			.appendTo("#expand")
			.css({top: wH - 50,left:5})
			.animate({opacity:0.3})
			.show(300)
			.click(function(){
				//$("#expand-img").animate({width: imW},{queue:false});
				window.open(ths.src);
				$("#expand").remove();
				return false;
			}).mouseover(function(){
				$("#expand-fimage").animate({opacity:0.9});
			}).mouseout(function(){
				$("#expand-fimage").animate({opacity:0.3});
			});
		}

		$("#expand-img").css({'padding':Marge / 2});
		var Lft = ((docW - (imW * vidnosh) ) / 2);
		$("#expand").css({top:ToP,left: Lft})
		.fadeIn(300)//show it
		.click(function(){
			$("#expand").fadeOut(300); // hide it
		});
	}
}

function spoiler(sp_id){
	var alt = $('#im_' + sp_id).attr('src');
	if(alt.toLowerCase().indexOf('plus.gif') > 0){
		$('#im_' + sp_id).attr({src:link_root +"templates/"+ template + "/system/sp-minus.gif"});
	} else {
		$('#im_' + sp_id).attr({src:link_root +"templates/"+ template + "/system/sp-plus.gif"});
	}
	$('#sp_' + sp_id).slideToggle('slow');
}
